import { defineStore } from 'pinia'
import { $get } from '@/lib/plugin/Aegis'

type RootState = {
  sideBarTagList: {
    id: number;
    title: string;
    head_img: string;
    tags: any;
    users: any;
    click: number;
    comment_total: number;
    star_total: number;
    created_at: string

  } | null;
};

export const tagStore = defineStore('tag', {
  state: () => {
    return {
      sideBarTagList: null
    } as RootState
  },
  getters: {},
  actions: {
    setSideBarTagList (res:any):void {
      this.sideBarTagList = res
    },
    async getSideBarTagList (params:any) {
      params ||= {
        nowPage: 1,
        pageSize: 10
      }
      try {
        this.sideBarTagList = (await $get('tag/list', params)).rows
      } catch (error) {
        console.log(error)
      }
    }
  }
})
